(function (a) {
    function c() {
        if (a('.preloader').length) {
            a('.preloader').delay(200).fadeOut(500)
        }
    }

    function d() {
        if (a('.main-header').length) {
            var k = a(window).scrollTop();
            var j = a('.main-header');
            var h = a('.main-header').height();
            var i = a('.scroll-to-top');
            if (k > h) {
                j.addClass('fixed-header');
                i.fadeIn(300)
            } else {
                j.removeClass('fixed-header');
                i.fadeOut(300)
            }
        }
    }

    d();
    if (a('.main-header li.dropdown ul').length) {
        a('.main-header .navigation li.dropdown').append('<div class="dropdown-btn"><span class="fa fa-angle-right"></span></div>');
        a('.main-header .navigation li.dropdown .dropdown-btn').on('click', function () {
            a(this).prev('ul').slideToggle(500)
        })
    }
    if (a('#search-popup').length) {
        a('.search-box-btn').on('click', function () {
            a('#search-popup').addClass('popup-visible')
        });
        a(document).keydown(function (h) {
            if (h.keyCode == 27) {
                a('#search-popup').removeClass('popup-visible')
            }
        });
        a('.close-search,.search-popup .overlay-layer').on('click', function () {
            a('#search-popup').removeClass('popup-visible')
        })
    }
    if (a('.mobile-menu').length) {
        a('.mobile-menu .menu-box').mCustomScrollbar();
        var e = a('.main-header .nav-outer .main-menu .navigation').html();
        a('.mobile-menu .navigation').append(e);
        a('.sticky-header .navigation').append(e);
        a('.mobile-menu .close-btn').on('click', function () {
            a('body').removeClass('mobile-menu-visible')
        });
        a('.mobile-menu li.dropdown .dropdown-btn').on('click', function () {
            a(this).toggleClass('open');
            a(this).prev('ul').slideToggle(500)
        });
        a('.mobile-nav-toggler').on('click', function () {
            a('body').addClass('mobile-menu-visible')
        });
        a(document).keydown(function (h) {
            if (h.keyCode == 27) {
                a('body').removeClass('mobile-menu-visible')
            }
        });
        a('.mobile-menu .menu-backdrop,.mobile-menu .close-btn').on('click', function () {
            a('body').removeClass('mobile-menu-visible')
        })
    }
    if (a('.banner-carousel').length) {
        a('.banner-carousel').owlCarousel({
            animateOut: 'fadeOut',
            animateIn: 'fadeIn',
            loop: true,
            margin: 0,
            nav: true,
            singleItem: true,
            smartSpeed: 500,
            autoplay: true,
            autoplayTimeout: 6000,
            navText: [
                '<span class="fas fa-angle-left"></span>',
                '<span class="fas fa-angle-right"></span>'
            ],
            responsive: {
                0: {
                    items: 1
                },
                600: {
                    items: 1
                },
                1024: {
                    items: 1
                }
            }
        })
    }
    if (a('.testimonial-carousel').length) {
        a('.testimonial-carousel').owlCarousel({
            animateOut: 'slideOutDown',
            animateIn: 'fadeIn',
            loop: true,
            margin: 30,
            nav: true,
            smartSpeed: 500,
            autoHeight: false,
            autoplay: true,
            autoplayTimeout: 10000,
            navText: [
                '<span class="fa fa-angle-left"></span>',
                '<span class="fa fa-angle-right"></span>'
            ],
            responsive: {
                0: {
                    items: 1
                },
                600: {
                    items: 1
                },
                800: {
                    items: 2
                },
                1024: {
                    items: 2
                },
                1200: {
                    items: 2
                }
            }
        })
    }
    if (a('.project-tab').length) {
        a('.project-tab .project-tab-btns .p-tab-btn').on('click', function (h) {
            h.preventDefault();
            var i = a(a(this).attr('data-tab'));
            if (a(i).hasClass('actve-tab')) {
                return false
            } else {
                a('.project-tab .project-tab-btns .p-tab-btn').removeClass('active-btn');
                a(this).addClass('active-btn');
                a('.project-tab .p-tabs-content .p-tab').removeClass('active-tab');
                a(i).addClass('active-tab')
            }
        })
    }
    if (a('.project-carousel').length) {
        a('.project-carousel').owlCarousel({
            loop: true,
            margin: 30,
            nav: true,
            smartSpeed: 700,
            autoplay: 5000,
            navText: [
                '<span class="fa fa-angle-left"></span>',
                '<span class="fa fa-angle-right"></span>'
            ],
            responsive: {
                0: {
                    items: 1
                },
                600: {
                    items: 2
                },
                800: {
                    items: 2
                },
                1024: {
                    items: 3
                },
                1200: {
                    items: 4
                },
                1400: {
                    items: 4
                }
            }
        })
    }

    function f() {
        if (a('.sortable-masonry').length) {
            var k = a(window);
            var h = a('.sortable-masonry .items-container');
            var i = a('.filter-btns');
            h.isotope({
                filter: '*',
                masonry: {
                    columnWidth: '.masonry-item.small-block'
                },
                animationOptions: {
                    duration: 500,
                    easing: 'linear'
                }
            });
            i.find('li').on('click', function () {
                var m = a(this).attr('data-filter');
                try {
                    h.isotope({
                        filter: m,
                        animationOptions: {
                            duration: 500,
                            easing: 'linear',
                            queue: false
                        }
                    })
                } catch (l) {
                }
                return false
            });
            k.on('resize', function () {
                var l = i.find('li.active').attr('data-filter');
                h.isotope({
                    filter: l,
                    animationOptions: {
                        duration: 500,
                        easing: 'linear',
                        queue: false
                    }
                })
            });
            var j = a('.filter-btns li');
            j.on('click', function () {
                var l = a(this);
                if (!l.hasClass('active')) {
                    j.removeClass('active');
                    l.addClass('active')
                }
            })
        }
    }

    f();

    function b() {
        if (a('.masonry-items-container').length) {
            var i = a(window);
            var h = a('.masonry-items-container');
            h.isotope({
                itemSelector: '.masonry-item',
                masonry: {
                    columnWidth: '.masonry-item.col-lg-4'
                },
                animationOptions: {
                    duration: 500,
                    easing: 'linear'
                }
            });
            i.on('resize', function () {
                h.isotope({
                    itemSelector: '.masonry-item',
                    animationOptions: {
                        duration: 500,
                        easing: 'linear',
                        queue: false
                    }
                })
            })
        }
    }

    b();
    if (a('.count-box').length) {
        a('.count-box').appear(function () {
            var h = a(this),
                i = h.find('.count-text').attr('data-stop'),
                j = parseInt(h.find('.count-text').attr('data-speed'), 10);
            if (!h.hasClass('counted')) {
                h.addClass('counted');
                a({
                    countNum: h.find('.count-text').text()
                }).animate({
                    countNum: i
                }, {
                    duration: j,
                    easing: 'linear',
                    step: function () {
                        h.find('.count-text').text(Math.floor(this.countNum))
                    },
                    complete: function () {
                        h.find('.count-text').text(this.countNum)
                    }
                })
            }
        }, {
            accY: 0
        })
    }
    if (a('.tabs-box').length) {
        a('.tabs-box .tab-buttons .tab-btn').on('click', function (h) {
            h.preventDefault();
            var i = a(a(this).attr('data-tab'));
            if (a(i).is(':visible')) {
                return false
            } else {
                i.parents('.tabs-box').find('.tab-buttons').find('.tab-btn').removeClass('active-btn');
                a(this).addClass('active-btn');
                i.parents('.tabs-box').find('.tabs-content').find('.tab').fadeOut(0);
                i.parents('.tabs-box').find('.tabs-content').find('.tab').removeClass('active-tab');
                a(i).fadeIn(300);
                a(i).addClass('active-tab')
            }
        })
    }
    if (a('.filter-list').length) {
        a('.filter-list').mixItUp({})
    }
    if (a('.custom-select-box').length) {
        a('.custom-select-box').selectmenu().selectmenu('menuWidget').addClass('overflow')
    }
    if (a('.quantity-spinner').length) {
        a('input.quantity-spinner').TouchSpin({
            verticalbuttons: true
        })
    }
    if (a('.lightbox-image').length) {
        a('.lightbox-image').fancybox({
            openEffect: 'fade',
            closeEffect: 'fade',
            helpers: {
                media: {}
            }
        })
    }
    if (a('#contact-form').length) {
        a('#contact-form').validate({
            rules: {
                username: {
                    required: true
                },
                email: {
                    required: true,
                    email: true
                },
                subject: {
                    required: true
                },
                message: {
                    required: true
                }
            }
        })
    }
    if (a('.scroll-to-target').length) {
        a('.scroll-to-target').on('click', function () {
            var h = a(this).attr('data-target');
            a('html, body').animate({
                scrollTop: a(h).offset().top
            }, 1500)
        })
    }
    if (a('.wow').length) {
        var g = new WOW({
            boxClass: 'wow',
            animateClass: 'animated',
            offset: 0,
            mobile: false,
            live: true
        });
        g.init()
    }
    a(window).on('scroll', function () {
        d()
    });
    a(window).on('load', function () {
        c();
        f();
        b()
    })
})(window.jQuery);
